package com.ibeeking.found.common.enums;

public enum PaymentWayEnum {
    CASH(0, "现金"),
    ALIPAY(1, "支付宝"),
    WX(2, "微信"),
    COUPON(3, "优惠券");

    private Integer code;
    private String name;

    PaymentWayEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public Integer getCode() {
        return code;
    }

    public static String getNameByCode(Integer code) {
        for (PaymentWayEnum enumObj : values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (PaymentWayEnum enumObj : values()) {
            if (enumObj.getName().equals(name)) {
                return enumObj.getCode();
            }
        }
        return null;
    }
}
